import Router from "koa-router";

const router = Router()


router.post('/fileUpload', (ctx, next) => {
  //判断是否为多个文件 单文件时为对象 多文件时为数组
  let len = ctx.request.files.file.length;
  let fileObj = ctx.request.files.file;
  if (len) {
    let arr = [];
    fileObj.forEach(file => {
      arr.push(file.newFilename);
      ctx.body = arr;
    })
  } else {
    ctx.body = fileObj.newFilename;

  }
});


export default router;